cc.PunchAction = cc.BezierTo.extend({
    _endPosition: null,
    ctor: function(t, c) {
        cc.BezierBy.prototype.ctor.call(this);
        this._toConfig = [];
        c && this.initWithDuration(t, c);
      },

    update: function(dt) {

        // cc.BezierTo.prototype.update.call(dt);

        dt = this._computeEaseTime(dt);
        if (this.target) {
          var locConfig = this._config;
          var xa = 0;
          var xb = locConfig[0].x;
          var xc = locConfig[1].x;
          var xd = locConfig[2].x;
          var ya = 0;
          var yb = locConfig[0].y;
          var yc = locConfig[1].y;
          var yd = locConfig[2].y;
          var x = cc.bezierAt(xa, xb, xc, xd, dt);
          var y = cc.bezierAt(ya, yb, yc, yd, dt);
          var locStartPosition = this._startPosition;
          if (cc.macro.ENABLE_STACKABLE_ACTIONS) {
            var targetX = this.target.getPositionX();
            var targetY = this.target.getPositionY();

            var locPreviousPosition = this._previousPosition;

            locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x;
            locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
            x += locStartPosition.x;
            y += locStartPosition.y;
            locPreviousPosition.x = x;
            locPreviousPosition.y = y;
            this.target.setPosition(x, y);

            //  余弦计算 照着jelly做的
            var distance = cc.pDistance(cc.p(targetX, targetY), cc.p(x, y));
            var dx = x - targetX;
            var dy = y - targetY;

            var rotation = Math.acos(dx / distance);
            if (dy < 0)
            {
                rotation = -1 * rotation;
            }
            rotation = 90 - rotation * 180 / Math.PI;

            // 正切计算 总是出错
            // var rotation = Math.atan((x - targetX) / (y - targetY)) * 180 / Math.PI ;

            this.target.rotation = rotation;
            // cc.log("Rotation : %f", rotation);
          } 
          else 
          {
            this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y);
          }
        }
      },
});

cc.punchAction = function(t, c) {
    return new cc.PunchAction(t, c);
  };